#include "root.h"
#include "ui_root.h"
#include "mainwindow.h"
#include <QMessageBox>
#include "id.h"
#include "agreeend.h"
#include "agreemoney.h"
#include "deleteperson.h"
#include <vector>
#include <program.h>
#include "addperson.h"
#include "bigsave.h"
#include "teacher.h"
#include "student.h"
#include "paper.h"
#include "agreepro.h"
#include "bigsave.h"
extern vector <Teacher*> tdata;
extern vector <student*> sdata;
extern vector <paper*> pdata;
extern vector <Program*> prdata;
extern id u;
extern int l;
root::root(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::root)
{
    ui->setupUi(this);
    ui->label->setText(u.str1);
}

root::~root()
{
    delete ui;
}

void root::on_pushButton_clicked()
{
    this->close();
    MainWindow*p=new(MainWindow);
    p->show();
}

void root::on_pushButton_6_clicked()
{
    int r=0;
      for(unsigned int i=0;i<prdata.size();i++){
          if(prdata[i]->agreeornot()){
              r=1;
              break;
          }
      }
      if(r==0){
      QMessageBox::information(this,"提示","没有结题申请，请返回");
      }
      else{
      this->hide();
     agreeend *p = new agreeend;
     p->show();}
}

void root::on_pushButton_3_clicked()
{
    this->hide();
    deleteperson*p=new(deleteperson);
    p->show();
}

void root::on_pushButton_2_clicked()
{
    this->hide();
    addperson*p=new(addperson);
    p->show();
}

void root::on_pushButton_5_clicked()
{
    int r=0;
      for(unsigned int i=0;i<prdata.size();i++){
          if(prdata[i]->ifaskmoney()){
              r=1;
              break;
          }
      }
      if(r==0){
      QMessageBox::information(this,"提示","没有项目申请资金，请返回");
      }
      else{
      this->hide();
     agreemoney*p = new agreemoney;
     p->show();}
}

void root::on_pushButton_4_clicked()
{
    int r=0;
      for(unsigned int i=0;i<prdata.size();i++){
          if(prdata[i]->showstatus()==3){
              r=1;
              break;
          }
      }
      if(r==0){
      QMessageBox::information(this,"提示","没有项目申请，请返回");
      }
      else{
    this->hide();
    agreepro *p = new agreepro;
    p->show();}

}
